package graphics.rendering;

import graphics.GraphicsManager;
import graphics.rendering.primitives.RenderPackage;

import java.util.LinkedList;
import java.util.Queue;

/**
 * An abstract implementation of a low-level graphics pipeline.
 * @author Joel Rausch
 */
public abstract class GraphicsPipeline {
	
	/** Collects primitives to be rendered. */
	protected final Queue<RenderPackage> renderQueue;
	
	/** Graphics manager reference. */
	protected final GraphicsManager manager;
	
	/**
	 * Constructor with argument for manager.
	 * @param manager
	 */
	public GraphicsPipeline(GraphicsManager manager) {
		renderQueue = new LinkedList<RenderPackage>();
		this.manager = manager;
	}
	
	/**
	 * Submit primitive to be rendered.
	 * @param renderPackage
	 */
	public void submitPrimitive(RenderPackage renderPackage) {
		renderQueue.add(renderPackage);
	}
	
	/**
	 * Clears primitives currently in the graphics pipeline.
	 */
	public void flushPipe() {
		renderQueue.clear();
	}
	
	/**
	 * Process all remaining primitives in the pipeline.
	 */
	public abstract void processPrimitives();
	
	/**
	 * Perform startup operations. Called by graphics manager
	 * before first usage.
	 */
	public abstract void setup();
	
	/**
	 * Perform cleanup operations. Called by graphics manager
	 * during shutdown.
	 */
	public abstract void shutdown();
}
